package tag

import org.apache.spark.broadcast.Broadcast
import org.apache.spark.sql.Row

object KeyTags extends Tags {
  override def makeTags(args: Any*): List[(String, Int)] = {
    //获取参数row
    val row = args(0).asInstanceOf[Row]
    val stopBc = args(1).asInstanceOf[Broadcast[Map[String,Null]]]
    //创建list
    var list = List[(String,Int)]()
    val keywords = row.getAs[String]("keywords")
    keywords.split("\\|", -1).filter(t => t.length >= 3 && t.length <= 8 && !stopBc.value.contains(t))
      .foreach(k => list :+= ("K" + k, 1))
    list
  }
}
